<?php
/**
 * MottoModel.class.php
 * 幸福语录模型
 * 
 * @author  王中艺 <wangzy_smile@qq.com>
 * @date    2017-05-21
 */

namespace Wechat\Model;

class MottoModel extends \Common\Model\MottoModel {

    protected $cache    = true;

    /**
     * 获取最新语录
     * @return  $mottoInfo
     */
    function getNewItem(){
        $mottoInfo  = $this->where('status = 1')->order('id desc')->cache(true)->find();
        $mottoInfo  = parent::resolveColumn($mottoInfo);
        return $mottoInfo;
    }

    /**
     * 获取详情信息
     * @param   $mottoId
     * @return  $mottoInfo
     */
    function getItem($mottoId){
        $mottoInfo  = $this->where('id = %d', $mottoId)->find();
        if(!$mottoInfo){
            $this->errMsg   = '指定条目未找到!';
            return false;
        }

        return parent::resolveColumn($mottoInfo);
    }
}